<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <div>
       <canvas id="cvs" width="400" height="400" style="border:1px solid black"></canvas>
    </div>
    <script>
       var canvas = document.getElementById('cvs');
       var ctx = canvas.getContext("2d");
       ctx.setLineDash([5,3,1])
       for(var i=0; i<256; i++) {
           ctx.beginPath()
           ctx.moveTo(100,100+i)
           ctx.lineTo(200,100+i)
           ctx.strokeStyle="rgb(0,"+i+",0)"
           ctx.stroke()
       }

    </script>
</body>
</html>